package com.kinyx.framework.db.sentence.res;

import com.kinyx.framework.db.configs.DBConfigs;

/**
 * 查询列子句
 */
public class SelectColumn extends Column {

	/** 列别名 */
	private String columnAlias;

	public SelectColumn(final Column column, final String columnAlias) {
		super(column);
		this.columnAlias = columnAlias;
	}

	@Override
	public String getSentence(final DBConfigs configs, final boolean isSQL, final boolean withTableAlias) {
		final String column = super.getSentence(configs, isSQL, withTableAlias);
		return this.columnAlias != null ? String.format("%s AS %s", column, this.columnAlias) : column;
	}

}
